package fr.sharpe.app.earthvisualizationproject.ui;

import java.awt.Dimension;

import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;

import fr.sharpe.app.earthvisualizationproject.tools.ImageFactory;

public class ImageView extends JFrame{

	private ImageIcon ico;

	public ImageView()
	{
		this.setTitle("Image");
		ico = new ImageIcon(ImageFactory.getImageFrom("local:images/logoBlack.png"));
		this.setPreferredSize(new Dimension(ico.getIconWidth(), ico.getIconHeight()));
		this.setMinimumSize(new Dimension(ico.getIconWidth(), ico.getIconHeight()));
		this.setMaximumSize(new Dimension(ico.getIconWidth(), ico.getIconHeight()));
		this.setTitle("local:images/logoBlack.png");
		JLabel pic = new JLabel(ico);
		this.add(pic);
		this.repaint();
		this.update(getGraphics());
	}
	
	public void diplayImage(String url)
	{
		ico.setImage(ImageFactory.getImageFrom(url));
		this.setPreferredSize(new Dimension(ico.getIconWidth(), ico.getIconHeight()));
		this.setMinimumSize(new Dimension(ico.getIconWidth(), ico.getIconHeight()));
		this.setMaximumSize(new Dimension(ico.getIconWidth(), ico.getIconHeight()));
		this.setTitle(url);
		this.repaint();
		this.update(getGraphics());
	}

}
